<template>
  <div>
    <van-nav-bar :title="comment.reply_count?comment.reply_count+'条回复':'暂无回复'">
      <template #left>
        <van-icon name="cross" @click="$emit('close-replay')" />
      </template>
    </van-nav-bar>

    <div class="scrop-wrop">
      <!-- 当前评论的信息 -->
      <CommentItem :comments="comment" />

      <!-- 评论回复 -->
      <van-cell title="评论回复"></van-cell>
      <ArticleComment type="c" :source="comment.com_id" :list="list" />
    </div>

    <div class="post-warp">
      <van-button round @click="showReplyComment=true">评论</van-button>
    </div>

    <!-- 回复评论弹出层 -->
    <van-popup v-model="showReplyComment" position="bottom">
      <ReplyPopup @onPutSuccess="onPutSuccess" :target="comment.com_id" :artId="$route.params.articleId" />
    </van-popup>
  </div>
</template>

<script>
import ReplyPopup from './comment-popup.vue'
import CommentItem from '@/components/comments-item.vue'
import ArticleComment from './article-comments.vue'
export default {
  name: 'Replay_comment',
  data () {
    return {
      list: [],
      showReplyComment: false
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  methods: {
    onPutSuccess (e) {
      this.showReplyComment = false
      this.list.unshift(e)
      this.comment.reply_count++
    }
  },
  computed: {},
  watch: {},
  filters: {},
  components: {
    CommentItem,
    ArticleComment,
    ReplyPopup
  },
  created () { },
  mounted () { }
}
</script>

<style scoped lang='less'>
.scrop-wrop {
  position: fixed;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow-y: scroll;
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgb(3, 184, 255);
  .van-button {
    width: 640px;
    height: 80px;
  }
}
</style>
